package myGuestbook;





import java.io.IOException;




import java.util.Date;






import javax.jdo.PersistenceManager;

import javax.servlet.ServletException;
import javax.servlet.http.*;

import com.google.appengine.api.users.User;

import com.google.appengine.api.users.UserService;

import com.google.appengine.api.users.UserServiceFactory;

import myGuestbook.Greeting;

import myGuestbook.PMF;

public class SignGuestbookServlet extends HttpServlet {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public void doGet(HttpServletRequest req, HttpServletResponse resp)

            throws ServletException, IOException {
		
	}

    public void doPost(HttpServletRequest req, HttpServletResponse resp)

                throws ServletException, IOException {

        UserService userService = UserServiceFactory.getUserService();

        User user = userService.getCurrentUser();

        String content = req.getParameter("content");

        Date date = new Date();





        Greeting greeting = new Greeting(user, content, date);







        PersistenceManager pm = PMF.get().getPersistenceManager();







        try {







            pm.makePersistent(greeting);







        } finally {







            pm.close();







        }

        resp.sendRedirect("mesg.jsp");
        

    }

}